from flask import render_template, request, jsonify, current_app
from . import tracking_bp
import os
from werkzeug.utils import secure_filename

@tracking_bp.route('/')
def index():
    return render_template('modules/object_tracking.html')

@tracking_bp.route('/process', methods=['POST'])
def process():
    if 'video' not in request.files:
        return jsonify({'success': False, 'message': '没有上传文件'})
    
    file = request.files['video']
    if file.filename == '':
        return jsonify({'success': False, 'message': '没有选择文件'})
    
    if file:
        filename = secure_filename(file.filename)
        file_path = os.path.join(current_app.config['UPLOAD_FOLDER'], filename)
        file.save(file_path)
        
        # 目标跟踪逻辑
        result = {
            'tracking_id': '12345',
            'status': '处理中'
        }
        
        return jsonify({
            'success': True,
            'result': result
        }) 